package comand.impl;

import comand.calulator.Calc;
import comand.Command;

@Deprecated
public class DefaultCommand extends Command {


    private Calc calc;
    private char operator;
    private int value;

    public DefaultCommand(Calc calc, char operator, int value) {
        this.calc = calc;
        this.operator = operator;
        this.value = value;
    }

    public Calc getCalculator() {
        return calc;
    }

    public void setCalculator(Calc calc) {
        this.calc = calc;
    }

    public char getOperator() {
        return operator;
    }

    public void setOperator(char operator) {
        this.operator = operator;
    }

    public int getValue() {
        return value;
    }

    public void setValue(int value) {
        this.value = value;
    }

    @Override
    public void execute() {
        calc.operation(operator, value);
    }


    @Override
    public void deExecute() {
        calc.operation(undo(operator), value);
    }

    private char undo(char operator2) {
        char ch = 0;
        switch (operator2) {
            case '+':
                ch = '-';
                break;
            case '-':
                ch = '+';
                break;
            case '*':
                ch = '/';
                break;
            case '/':
                ch = '*';
                break;
        }
        return ch;
    }
}
